from django.shortcuts import render
from rest_framework.views import Response, APIView
from .models import *
from rest_framework.viewsets import ModelViewSet
from .serializers import *


# Create your views here.

# 交易所
class ExchangeAPIView(APIView):
    def get(self, request):
        exchange = ExchangeModel.objects.all()
        exchange_ser = ExchangeSer(exchange, many=True)
        return Response({'code': 200, 'msg': '获取所有的交易对成功！', 'data': exchange_ser.data})


# 货币
class CurrencyMViewSet(ModelViewSet):
    queryset = CurrencyModel.objects.all()
    serializer_class = CurrencySer
    lookup_field = "pk"
    lookup_url_kwarg = "pk"
